package com.telnetnz.ticketdesk.action.base;

import org.apache.log4j.Logger;

import com.rockbb.common.sso.acl.ACLUtils;
import com.telnetnz.ticketdesk.bean.User;
import com.telnetnz.ticketdesk.service.UserService;

public class BasicSessionAccAction extends BasicSessionAction
{
	private static Logger logger = Logger.getLogger(BasicSessionAccAction.class);

	public String intercepters()
	{
		String result = super.intercepters();

		if (result == null || result.equals(SUCCESS))
		{
			User user = getSessionUser();

			// Verify in-activated users
			if (user.getStatus() == UserService.USER_STATUS_INACTIVATED)
			{
				return ERROR;
			}

			// Verify Permissions. Skip the permission check if it is a superuser
			if (!this.isSuperSession() 
					&& !ACLUtils.accVerify(user.getPermissions(), getContext().getAccesses()))
			{
				return ERROR;
			}
		}

		return result;
	}
}
